<html>
<head><meta charset="utf-8"><title>build error with address sanitizer · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/build.20error.20with.20address.20sanitizer.html">build error with address sanitizer</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228152781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/build%20error%20with%20address%20sanitizer/near/228152781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shihao Xia <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/build.20error.20with.20address.20sanitizer.html#228152781">(Feb 28 2021 at 19:59)</a>:</h4>
<p>I am trying to build a simple rust program with Address Sanitizer:</p>
<p>Cargo.toml</p>
<div class="codehilite"><pre><span></span><code>[package]
name = &quot;serde&quot;
version = &quot;0.0.1&quot;
edition = &#39;2018&#39;

[[bin]]
name = &quot;serde&quot;
path = &quot;main.rs&quot;

[dependencies]
serde = { version = &quot;1.0&quot;, features = [&quot;derive&quot;] }
serde_json = &quot;1.0&quot;
</code></pre></div>
<p>Rust Compiler: rustc 1.46.0-dev (sanitizer = true in config.toml)</p>
<p>Command I am using: RUSTFLAGS="-Zsanitizer=address --cfg procmacro2_semver_exempt" cargo build</p>
<p>error: /home/xsh/code/rust-asan/crate-examples/target/asan/debug/deps/libserde_derive-95921aa8ba419778.so: undefined symbol: __asan_option_detect_stack_use_after_return<br>
   --&gt; /home/xsh/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.123/src/lib.rs:293:1<br>
    |<br>
293 | extern crate serde_derive;<br>
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^</p>
<p>error: aborting due to previous error</p>
<p>error: could not compile <code>serde</code>.</p>
<p>Does anyone know how to fix this issue?</p>



<a name="228152946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/build%20error%20with%20address%20sanitizer/near/228152946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/build.20error.20with.20address.20sanitizer.html#228152946">(Feb 28 2021 at 20:01)</a>:</h4>
<p>Provide a <code>--target</code> flag to cargo.</p>



<a name="228153303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/build%20error%20with%20address%20sanitizer/near/228153303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/build.20error.20with.20address.20sanitizer.html#228153303">(Feb 28 2021 at 20:06)</a>:</h4>
<p><code>--target</code> will make cargo ignore <code>RUSTFLAGS</code> for all things that need to be compiled for the host system like proc macros and build scripts. This happens even when the target you choose is the host target. In your case probably <code>--target x86_64-unknown-linux-gnu</code>.</p>



<a name="228175535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/build%20error%20with%20address%20sanitizer/near/228175535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shihao Xia <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/build.20error.20with.20address.20sanitizer.html#228175535">(Mar 01 2021 at 02:53)</a>:</h4>
<p><span class="user-mention" data-user-id="352985">@tm</span> <span class="user-mention" data-user-id="133247">@bjorn3</span> Thank you. It works!!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>